package registeringSystem;

import junit.framework.Test;
import junit.framework.TestCase;
import junit.framework.TestSuite;

public class MonthDayYearTest extends TestCase 
{
	/** 
     * Name: testConstructor1 <br><br>
     * Checks if constructor will throw an exception if a negative number is 
     * passed in for the first argument. 
     */
	public void testConstructor1()
	{
		try
		{
		    MonthDayYear abc = new MonthDayYear(-1, 1, 1);
		    fail("Should throw an exception because a negative was entered " +
		         "for the first argument");
		}
		
		catch(NotValidArgumentException nvae)
		{
			; // do nothing
		}
	} // end of testConstructor1()
	
	
	
	/** 
     * Name: testConstructor2 <br><br>
     * Checks if constructor will throw an exception if a negative number is 
     * passed in for the first argument. 
     */
	public void testConstructor2()
	{
		try
		{
		    MonthDayYear abc = new MonthDayYear(1, -1, 1);
		    fail("Should throw an exception because a negative was entered " +
		         "for the second argument");
		}
		
		catch(NotValidArgumentException nvae)
		{
			; // do nothing
		}
	} // end of testConstructor2()
	
	
	
	/** 
     * Name: testConstructor3 <br><br>
     * Checks if constructor will throw an exception if a negative number is 
     * passed in for the third argument. 
     */
	public void testConstructor3()
	{
		try
		{
		    MonthDayYear abc = new MonthDayYear(1, 1, -1);
		    fail("Should throw an exception because a negative was entered " +
		         "for the first argument");
		}
		
		catch(NotValidArgumentException nvae)
		{
			; // do nothing
		}
	} // end of testConstructor3()
	
	
	
	/** 
     * Name: testConstructor4 <br><br>
     * Checks if constructor will throw an exception if a value greater than
     * 11 was passed into the month field.  December is represented by 11. 
     */
	public void testConstructor4()
	{
		try
		{
		    MonthDayYear abc = new MonthDayYear(12, 1, 1);
		    fail("Should throw an exception because a negative was entered " +
		         "for the first argument");
		}
		
		catch(NotValidArgumentException nvae)
		{
			; // do nothing
		}
	} // end of testConstructor4()
	
	
	
	/** 
     * Name: testConstructor4 <br><br>
     * Checks if copy constructor will throw an exception because a null
     * reference was passed in. 
     */
	public void testConstructor5()
	{
		try
		{
		    MonthDayYear abc = new MonthDayYear(12, 1, 1);
		    MonthDayYear def = new MonthDayYear(abc);
		    fail("Should throw an exception because a null reference was " +
		         "passed in.\n");
		}
		
		catch(NotValidArgumentException nvae)
		{
			; // do nothing
		}
		
		catch(NullReferenceException nre)
		{
			; // do nothing
		}
	} // end of testConstructor5()
	
	
	
	/** 
     * Name: testConstructor6 <br><br>
     * Checks that the copy constructor performs a deep copy. 
     */
	public void testConstructor6()
	{
		try
		{
		    MonthDayYear abc = new MonthDayYear(12, 1, 1);
		    MonthDayYear def = new MonthDayYear(abc);
		    assertTrue(def.getMonth() == 12);
		    assertTrue(def.getDay() == 1);
		    assertTrue(def.getYear() == 1);
		}
		
		catch(NotValidArgumentException nvae)
		{
			; // do nothing
		}
		
		catch(NullReferenceException nre)
		{
			; // do nothing
		}
	} // end of testConstructor6()
	
	
	
	/** 
     * Name: testSetMonth1 <br><br>
     * Checks if the setMonth() will throw an exception when a negative number
     * is passed in.
     */
	public void testSetMonth1()
	{
		try
		{
		    MonthDayYear abc = new MonthDayYear();
		    abc.setMonth(-1);
		    fail("Should throw an exception because a negative was entered " +
		         "for the first argument");
		}
		
		catch(NotValidArgumentException nvae)
		{
			; // do nothing
		}
	} // end of testSetMonth1()
	
	
	
	/** 
     * Name: testSetMonth <br><br>
     * Checks if the setMonth() will throw an exception if the number passed in
     * is greater than 11.  December is represented by 11.
     */
	public void testSetMonth()
	{
		try
		{
		    MonthDayYear abc = new MonthDayYear();
		    abc.setMonth(15);
		    fail("Should throw an exception because the calendar does not " +
		    	 "have more than 12 months");
		}
		
		catch(NotValidArgumentException nvae)
		{
			; // do nothing
		}
	} // end of testSetMonth()
	
	
	
	/** 
     * Name: testSetDay <br><br>
     * Checks if the setDay() will throw an exception when a negative number
     * is passed in.
     */
	public void testSetDay()
	{
		try
		{
		    MonthDayYear abc = new MonthDayYear();
		    abc.setDay(-1);
		    fail("Should throw an exception because a negative was entered " +
		         "for the first argument");
		}
		
		catch(NotValidArgumentException nvae)
		{
			; // do nothing
		}
	} // end of testSetDay()
	
	
	
	/** 
     * Name: testSetYear <br><br>
     * Checks if the setYear() will throw an exception when a negative number
     * is passed in.
     */
	public void testSetYear()
	{
		try
		{
		    MonthDayYear abc = new MonthDayYear();
		    abc.setYear(-1);
		    fail("Should throw an exception because a negative was entered " +
		         "for the first argument");
		}
		
		catch(NotValidArgumentException nvae)
		{
			; // do nothing
		}
	} // end of testSetYear()
	
	
		
	/** 
     * Name: testCheckIfCalendarDateIsValid1 <br><br>
     * Checks if the date passed in is valid.  The numbers passed in should
     * produce a non-empty String because 2-30-1 should not exist.  February
     * should have either 28 or 29 (a leap year) days in that month.
     */
	public void testCheckIfCalendarDateIsValid1()
	{
		try
		{
		    String result = 
		    	MonthDayYear.checkIfTheCalendarDateIsValid(1, 30, 1);
		    assertFalse(result.equals(""));
		}
		
		catch(NotValidArgumentException nvae)
		{
			; // do nothing
		}
	} // end of testCheckIfCalendarDateIsValid1()
	
	
	
	/** 
     * Name: testCheckIfCalendarDateIsValid2 <br><br>
     * Checks if the date passed in is valid.  The numbers passed in should
     * produce a non-empty String because 2-29-1 should not exist, this year
     * is not a leap year
     */
	public void testCheckIfCalendarDateIsValid2()
	{
		try
		{
		    String result = 
		    	MonthDayYear.checkIfTheCalendarDateIsValid(1, 29, 1);
		    assertFalse(result.equals(""));
		}
		
		catch(NotValidArgumentException nvae)
		{
			; // do nothing
		}
	} // end of testCheckIfCalendarDateIsValid2()
	
	
	
	/** 
     * Name: testCheckIfCalendarDateIsValid3 <br><br>
     * Checks if the date passed in is valid.  The numbers passed in should
     * produce an empty String because 2-29-2008 should not exist, this year
     * IS a leap year.
     */
	public void testCheckIfCalendarDateIsValid3()
	{
		try
		{
		    String result = 
		    	MonthDayYear.checkIfTheCalendarDateIsValid(1, 29, 2008);
		    assertTrue(result.equals(""));
		}
		
		catch(NotValidArgumentException nvae)
		{
			; // do nothing
		}
	} // end of testCheckIfCalendarDateIsValid3()
	
	
	
	/** 
     * Name: testEquals1 <br><br>
     * Tests the equals method.  The equals should return true. 
     */
	public void testEquals1()
	{
		try
		{
		    MonthDayYear abc = new MonthDayYear(0, 1, 1);
		    MonthDayYear def = new MonthDayYear(0, 1, 1);
		    assertTrue(abc.equals(def));
		}
		
		catch(NotValidArgumentException nvae)
		{
			; // do nothing
		}
	} // end of testEquals1()
	
	
	
	/** 
     * Name: testEquals2 <br><br>
     * Tests the equals method.  The equals should return false. 
     */
	public void testEquals2()
	{
		try
		{
		    MonthDayYear abc = new MonthDayYear(0, 1, 1);
		    MonthDayYear def = new MonthDayYear(10, 11, 11);
		    assertFalse(abc.equals(def));
		}
		
		catch(NotValidArgumentException nvae)
		{
			; // do nothing
		}
	} // end of testEquals2()
	
	
	
	/** 
     * Name: testEquals3 <br><br>
     * Tests the equals method with a null reference.  The equals should 
     * return false. 
     */
	public void testEquals3()
	{
		try
		{
		    MonthDayYear abc = new MonthDayYear(0, 1, 1);
		    MonthDayYear def = null;
		    assertFalse(abc.equals(def));
		}
		
		catch(NotValidArgumentException nvae)
		{
			; // do nothing
		}
	} // end of testEquals3()
	
	
	
	/** 
     * Name: testCompareTo <br><br>
     * Tests the compareTo method.  Since "abc" comes before "def" the
     * compareTo method should produce -1. 
     */
	public void testCompareTo()
	{
		try
		{
		    MonthDayYear abc = new MonthDayYear(0, 1, 1);
		    MonthDayYear def = new MonthDayYear(10, 11, 11);
		    assertTrue(abc.compareTo(def) == -1);
		}
		
		catch(NotValidArgumentException nvae)
		{
			; // do nothing
		}
	} // end of equals1()
	
	
	
	/** 
     * Name: suite <br><br>
     * Runs all of the test cases specified in the class.  Returns a TestSuite
     * object to test this class with JUnit.
     */
    public static Test suite()
    {
    	return new TestSuite(MonthDayYearTest.class);
    } // end of suite()
} // end of MonthDayYearTest class
